<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>{{title}} - 图腾生命医学</title>
    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="/apps/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="/apps/css/fontawesome-free-6.4.0-web/css/all.css">
    <!-- AdminLTE CSS -->
    <link rel="stylesheet" href="/apps/css/adminlte.min.css">
</head>
<body class="hold-transition">
    <div class="wrapper">
        <div class="container-fluid">
            <div class="row">
                <div class="col-md-12">
                    <div class="card">
                        <div class="card-header">
                            <h3 class="card-title">{{title}}</h3>
                            <div class="card-tools">
                                <a href="/apps/admin/surveys" class="btn btn-tool">
                                    <i class="fas fa-arrow-left"></i> 返回列表
                                </a>
                            </div>
                        </div>
                        <div class="card-body">
                            <form id="surveyForm" action="/apps/admin/surveys" method="POST">
                                <input type="hidden" name="isNew" value="{{isNew}}">

                                <div class="form-group row">
                                    <label class="col-sm-2 col-form-label">问卷代码</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" name="program_code" 
                                            value="{{survey.program_code}}" 
                                            {{#unless isNew}}readonly{{/unless}}
                                            pattern="[A-Z]+-\d{4}-\d{2}-\d{2}"
                                            title="格式：SVY-2024-03-21"
                                            required>
                                        <small class="form-text text-muted">格式：SVY-2024-03-21</small>
                                    </div>
                                </div>

                                <div class="form-group row">
                                    <label class="col-sm-2 col-form-label">问卷名称</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" name="title" 
                                            value="{{survey.title}}" required>
                                    </div>
                                </div>

                                <div class="form-group row">
                                    <label class="col-sm-2 col-form-label">问卷来源</label>
                                    <div class="col-sm-10">
                                        <select class="form-control" name="source" required>
                                            <option value="MTA" {{#if (eq survey.source 'MTA')}}selected{{/if}}>MTA自有系统</option>
                                            <option value="TENCENT" {{#if (eq survey.source 'TENCENT')}}selected{{/if}}>腾讯问卷</option>
                                            <option value="WECOM" {{#if (eq survey.source 'WECOM')}}selected{{/if}}>企业微信问卷</option>
                                        </select>
                                    </div>
                                </div>

                                <div class="form-group row">
                                    <label class="col-sm-2 col-form-label">问卷状态</label>
                                    <div class="col-sm-10">
                                        <select class="form-control" name="status" required>
                                            <option value="OPEN" {{#if (eq survey.status 'OPEN')}}selected{{/if}}>开放访问</option>
                                            <option value="CLOSED" {{#if (eq survey.status 'CLOSED')}}selected{{/if}}>关闭访问</option>
                                        </select>
                                    </div>
                                </div>

                                <div class="form-group row">
                                    <label class="col-sm-2 col-form-label">合格条件</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" name="conditions" 
                                            value="{{survey.conditions}}" required>
                                        <small class="form-text text-muted">JavaScript条件表达式，例如：u.status=1 表示只用于未拉黑用户</small>
                                    </div>
                                </div>

                                <div class="form-group row">
                                    <label class="col-sm-2 col-form-label">参与说明</label>
                                    <div class="col-sm-10">
                                        <textarea class="form-control" name="description" 
                                            rows="3">{{survey.description}}</textarea>
                                        <small class="form-text text-muted">用于描述参与条件及规则</small>
                                    </div>
                                </div>

                                <div class="form-group row">
                                    <label class="col-sm-2 col-form-label">问卷入口</label>
                                    <div class="col-sm-10">
                                        <input type="url" class="form-control" name="entry_url" 
                                            value="{{survey.entry_url}}" required>
                                        <small class="form-text text-muted">用户符合条件时跳转的问卷地址</small>
                                    </div>
                                </div>

                                <div class="form-group row">
                                    <label class="col-sm-2 col-form-label">返回地址</label>
                                    <div class="col-sm-10">
                                        <input type="url" class="form-control" name="return_url" 
                                            value="{{survey.return_url}}">
                                        <small class="form-text text-muted">用户完成问卷后的跳转地址（可选）</small>
                                    </div>
                                </div>

                                <div class="form-group row">
                                    <label class="col-sm-2 col-form-label">数据查看地址</label>
                                    <div class="col-sm-10">
                                        <input type="url" class="form-control" name="data_url" 
                                            value="{{survey.data_url}}">
                                        <small class="form-text text-muted">问卷数据查看地址（可选）</small>
                                    </div>
                                </div>

                                <div class="form-group row">
                                    <div class="col-sm-10 offset-sm-2">
                                        <button type="submit" class="btn btn-primary">保存问卷</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- jQuery -->
    <script src="/apps/js/jquery.min.js"></script>
    <!-- Bootstrap JS -->
    <script src="/apps/js/bootstrap.bundle.min.js"></script>
    <!-- AdminLTE JS -->
    <script src="/apps/js/adminlte.min.js"></script>
</body>
</html> 